@use 'sass:map';

@use './shared' as *;
@use './design' as *;
@use './input' as input;

$textarea: () !default;
$textarea: map.merge(
  (
    min-height: 32px,
    resize: vertical,
    count-color: value('input-count-color'),
    count-color-disabled: value('input-count-color-disabled'),
    count-font-size: value('input-count-font-size'),
    count-line-height: value('input-count-line-height')
  ),
  $textarea
);

.#{$namespace}-textarea {
  &-vars {
    @include define-preset-values('textarea', $textarea);
  }

  @include basis;
  @include input.handler;

  @at-root & {
    height: auto;
    min-height: value('textarea-min-height');
    padding: 0;
    overflow: hidden;
  }

  &__control {
    height: auto;
    padding: value('input-v-padding') value('input-h-padding');
    overflow: hidden auto;
    font-family: inherit;
    font-feature-settings: 'tnum';
    font-variant-numeric: inherit;
    resize: value('textarea-resize');
  }

  &--no-resize &__control {
    resize: none;
  }

  &__extra {
    position: absolute;
    inset-inline-end: 7px;
    bottom: 4px;
    display: flex;
    align-items: center;
  }

  &__loading {
    position: relative;
    inset-inline-end: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: value('input-icon-color');
    pointer-events: none;
    user-select: none;
  }

  &__count {
    margin-inline-start: 4px;
    font-size: value('textarea-count-font-size');
    line-height: value('textarea-count-line-height');
    color: value('textarea-count-color');
    pointer-events: none;
    user-select: none;
    transition: value('transition-color');
  }

  &--disabled &__count {
    color: value('textarea-count-color-disabled');
  }
}
